package com.learn.dubbo;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * @auther liuhw
 * @date 2019/11/20 10:05
 * @description:
 * @since 1.0
 **/
@SpringBootApplication
@EnableAutoConfiguration
public class DubboClientSpringBootStarter implements CommandLineRunner {
    @Reference(url = "dubbo://127.0.0.1:8899", version = "1.0.0")
    private IDemoService demoService;

    public static void main(String[] args) {
        System.setProperty("java.net.preferIPv4Stack", "true");
        SpringApplication.run(DubboClientSpringBootStarter.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        System.out.println(demoService.sayHello(args.length == 0 ? "world" : args[0]));
    }
}
